import { TBoss } from "../../../Message/Db/Tables/TBoss";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
import { BossInfo } from "./info/BossInfo";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { ModelShowToolVo } from "../view/modelShowTool/ModelShowToolVo";
import { ModelType } from "../scene/modle/data/ModelType";
type int = number;
//class BossConfig
    
    export  class BossConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            if (BossConfig._instance != null) 
            {
                throw new Error(" BossConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=0;
            var loc5=arg1;
            for(loc2 of loc5) 
            {
                loc1 = new TBoss();
                loc1.code = loc2.code;
                loc1.name = StringHelper.getString(loc2.name);
                loc1.level = loc2.level;
                loc1.attackModel = loc2.attackModel;
                loc1.camp = loc2.camp;
                loc1.type = loc2.type;
                loc1.subType = loc2.subType;
                loc1.avatarId = loc2.avatarId;
                loc1.modelId = loc2.modelId;
                loc1.speed = loc2.speed;
                loc1.attackSpeed = loc2.attackSpeed;
                loc1.attackDistance = loc2.attackDistance;
                loc1.visionRange = StringHelper.getString(loc2.visionRange);
                loc1.attackRange = loc2.attackRange;
                loc1.physicalAttack = loc2.physicalAttack;
                loc1.magicAttack = loc2.magicAttack;
                loc1.maxLife = loc2.maxLife;
                loc1.maxMana = loc2.maxMana;
                loc1.physicalDefense = loc2.physicalDefense;
                loc1.magicDefense = loc2.magicDefense;
                loc1.reliefRate = loc2.reliefRate;
                loc1.hitRate = loc2.hitRate;
                loc1.joukRate = loc2.joukRate;
                loc1.passRate = loc2.passRate;
                loc1.blockRate = loc2.blockRate;
                loc1.showType = loc2.showType;
                loc1.physicalCritRate = loc2.physicalCritRate;
                loc1.magicCritRate = loc2.magicCritRate;
                loc1.speededUpRate = loc2.speededUpRate;
                loc1.toughnessRate = loc2.toughnessRate;
                loc1.skillPublicCd = loc2.skillPublicCd;
                loc1.skillList = StringHelper.getString(loc2.skillList);
                loc1.experienceDrop = loc2.experienceDrop;
                loc1.moneyDrop = StringHelper.getString(loc2.moneyDrop);
                loc1.itemDropId1 = loc2.itemDropId1;
                loc1.itemDropId2 = loc2.itemDropId2;
                loc1.itemDropId3 = loc2.itemDropId3;
                loc1.aiBase = loc2.aiBase;
                loc1.aiEx = loc2.aiEx;
                loc1.talkId = loc2.talkId;
                loc1.live = loc2.live;
                loc1.route = StringHelper.getString(loc2.route);
                loc1.notResertStatus = loc2.notResertStatus;
                loc3 = new BossInfo(loc1);
                this._map[loc1.code] = loc3;
            }
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_boss.json");
            this.write(loc1);
            return;
        }

        public getInfoByName(arg1: int): TBoss
        {
            var loc1=this._map[arg1];
            if (loc1) 
            {
                return loc1.boss;
            }
            return null;
        }

        public getInfoByCode(arg1: int): BossInfo
        {
            return this._map[arg1];
        }

        public BossConfig.get allBoss(): Array<any>
        {
            var loc2=null;
            var loc4=null;
            var loc5=null;
            var loc1="";
            var loc3=[];
            var loc6=0;
            var loc7=this._map;
            for (loc5 in loc7) 
            {
                loc2 = BossInfo(this._map[loc5]).modelId;
                if (!(int(loc2) > 0 && loc1.indexOf(loc2) == -1)) 
                {
                    continue;
                }
                loc1 = loc1 + (loc2 + ",");
                (loc4 = new ModelShowToolVo()).id = BossInfo(this._map[loc5]).modelId;
                loc4.modelType = ModelType.Item;
                loc3.push(loc4);
            }
            return loc3;
        }

        public getBossByShowType(arg1: int): Array<any>
        {
            var loc2=null;
            var loc3=null;
            var loc1=[];
            var loc4=0;
            var loc5=this._map;
            for (loc3 in loc5) 
            {
                loc2 = BossInfo(this._map[loc3]);
                if (loc2.boss.showType != arg1) 
                {
                    continue;
                }
                loc1.push(loc2);
            }
            return loc1;
        }

        public static get instance(): BossConfig
        {
            if (BossConfig._instance == null) 
            {
                BossConfig._instance = new BossConfig();
            }
            return BossConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: BossConfig;
    }
